package com.aizuda.boot.modules.business.country.controller;

import com.aizuda.boot.modules.business.contract.dto.SingleResponse;
import com.aizuda.boot.modules.common.constant.enums.CountryEnum;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @Author sangyirong
 * @ClassName CountryController
 * @Version 1.0
 * @Date 2025/6/19 11:12
 */
@Slf4j
@RestController
@RequestMapping("country")
@Tag(description = "country", name = "国家信息接口")
public class CountryController {

    @GetMapping("list")
    public SingleResponse<List<HashMap<String, String>>> list() {
        CountryEnum[] values = CountryEnum.values();
        List<HashMap<String, String>> collect = Arrays.stream(values).map(item -> {
            HashMap<String, String> map = new HashMap<>();
            map.put("countryName", item.getCountryName());
            map.put("countryEnglishName", item.getCountryEnglishName());
            map.put("countryCode", item.getCountryCode());
            map.put("countryMdmCode", item.getCountryMdmCode());
            map.put("language", item.getLanguage());
            return map;
        }).collect(Collectors.toList());
        return SingleResponse.of(collect);
    }
}
